import React, { useCallback } from 'react'
import { useSelector, useDispatch } from 'react-redux'

import CategoryUi from '../ui/CategoryUi'
import { actionCreator as ac } from '@/home/category'


const Category = () => {

  const cateType = useSelector(state => state.getIn(['category', 'routeInfo','cateType'])) 
  const dispatch = useDispatch()

  const handleClick = useCallback((type) => {
    return () => {
      dispatch(ac.changeCateType(type))
      dispatch(ac.changeCateAside(type))
    }
  }, [])

  return (
    <CategoryUi
      type={cateType}
      onCategoryUiClick={handleClick}
    ></CategoryUi>
  )

}

export default Category